from django.core.management.base import BaseCommand
from django.db import connection, transaction
import os
from django.core.management import call_command
import io
class Command(BaseCommand):
    help = 'Reset db sequence'

    def handle(self, *args, **options):

        output = io.StringIO()
        call_command('sqlsequencereset', 'frontend_api', stdout=output, no_color=True)
        call_command('sqlsequencereset', 'users', stdout=output, no_color=True)
        sql = output.getvalue()
        with connection.cursor() as cursor:
            cursor.execute(sql)

        self.stdout.write(self.style.SUCCESS('Database data migrations complete.'))